﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UtilZ.Dotnet.Ex.Config;

namespace UtilZ.Tool.HostCore
{
    [ConfigRoot("Config")]
    public class Config : IConfig
    {

        private int _httpPort = 5200;
        /// <summary>
        /// http监听端口
        /// </summary>
        [ConfigItem("HttpPort", "http监听端口,小于0使用默认端口号5200")]
        public int HttpPort
        {
            get { return _httpPort; }
            set
            {
                if (value <= 0)
                {
                    _httpPort = 5200;
                }
                else
                {
                    _httpPort = value;
                }
            }
        }


        /// <summary>
        /// 插件初始化和启动顺序列表,不在列表中表示无顺序关系
        /// </summary>
        [ConfigCollection("PluginLoadInfoList", "PluginLoadInfo", "插件初始化和启动顺序列表,不在列表中表示无顺序关系", true)]
        public List<PluginLoadInfo> PluginLoadInfoList { get; set; }







        #region single instance
        private readonly static Config _inctance;
        public static Config Instance
        {
            get { return _inctance; }
        }

        static Config()
        {
            _inctance = ConfigHelper.Load<Config>();
        }
        #endregion




        /// <summary>
        /// 
        /// </summary>
        public Config()
            : base()
        {

        }

        /// <summary>
        /// 
        /// </summary>
        public void InitDefaultValue()
        {
            this.PluginLoadInfoList = new List<PluginLoadInfo>()
            {
                new PluginLoadInfo(){PluginID=@"B0CC06B1-4A4C-4A20-B251-A0F08FE573D2",OrderIndex = 1,Des="Watchdog" },
                new PluginLoadInfo(){PluginID=@"08042002-7E83-4087-BAFF-F60A707E1F88",OrderIndex = 2,Des="GCBOM" },
            };
        }
    }
    
}
